﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DataAccessLayer;
using BusinessLogicLayer;
using System.Data.SqlClient;
using System.IO;
using System.Drawing;
using System.Data;

namespace ChamCong.Admin
{
    public partial class XemLuong : BasePage
    {
        CT_LuongThangBLL ctlBLL = new CT_LuongThangBLL();

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                txtNam.Text = DateTime.Now.Year.ToString();
                drThang.SelectedValue = DateTime.Now.Month.ToString();

                //LoadReport(11, 2012, "", 0);
            }
        }

        protected void LoadReport(int _thang, int _nam, string _hoten, int _mapb)
        {
            var source =
                new Microsoft.
                Reporting.
                WebForms.
                ReportDataSource("dsBangLuong", new CT_LuongThangBLL().LayBangLuong(_thang, _nam, _mapb, _hoten));

            repv.LocalReport.ReportPath = "Report/BangLuongReport.rdlc";
            repv.LocalReport.DataSources.Clear();
            repv.LocalReport.DataSources.Add(source);
            repv.LocalReport.Refresh();
        }

        protected void btnXem_Click(object sender, EventArgs e)
        {
            string _ten = txtNhanVien.Text;
            int _mapb = int.Parse(drPhongBan.SelectedValue);

            int _thang = int.Parse(drThang.SelectedValue);
            int _nam = int.Parse(txtNam.Text);

            LoadReport(_thang, _nam, _ten, _mapb);
        }

        protected void btnAll_Click(object sender, EventArgs e)
        {
            string _ten = "";
            int _mapb = 0;

            int _thang = int.Parse(drThang.SelectedValue);
            int _nam = int.Parse(txtNam.Text);

            LoadReport(_thang, _nam, _ten, _mapb);
        }
    }
}